package com.tsmti.lab.controller.basedata;

import com.tsmti.basicdata.entity.WardInformation;
import com.tsmti.core.common.constant.RedisConstants;
import com.tsmti.core.common.controller.BaseCrudController;
import com.tsmti.core.common.query.data.Queryable;
import com.tsmti.core.util.RedisUtils;
import com.tsmti.shiro.annotation.RequiresPathPermission;
import org.hibernate.criterion.DetachedCriteria;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by  on 2018/7/12.
 * @author zjn
 */
@RequiresPathPermission("baseData:ward")
@RequestMapping("/baseData/ward")
@Controller
public class WardInfomationController extends BaseCrudController<WardInformation, Long> {
    @Override
    public void preAjaxList(Queryable queryable, DetachedCriteria detachedCriteria, HttpServletRequest request,
                            HttpServletResponse response) {
    }

    @Override
    public String showCreate(WardInformation wardInformation, Model model, HttpServletRequest request, HttpServletResponse response) {
        return display("create");
    }

    @Override
    public void afterSave(WardInformation entity, HttpServletRequest request, HttpServletResponse response) {
        try {
            RedisUtils.setObject(RedisConstants.WARD_CACHE, entity.getCode(), entity);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
